<?php

namespace App\Service\UserCenter\v1_2_1;

use App\Constants\ErrorCode;
use App\Helpers\AliyunUtil;
use App\Model\ProfileVerifyLog;
use App\Model\UserProfile;
use App\Service\BaseService;

/**
 * 微信认证
 */
class WechatSubmitService extends BaseService
{
    protected function RoVerifyList()
    {
        return [
            'wechat_account' => 'required|string',
            'wechat_qrcode' => '|string'
        ];
    }

    public function handle()
    {
        $userId = $this->getUserId();
        $profile = UserProfile::getProfile($userId);
        if ($profile->gender == 1) {
            return $this->setError(ErrorCode::OP_NOT_VALID, '暂时不能提交微信认证~');
        }

        $wechatAccount = $this->request->input('wechat_account', '');
        $wechatQrcode = $this->request->input('wechat_qrcode', '');
        ProfileVerifyLog::addRecord(
            $this->userId,
            ProfileVerifyLog::TYPE_WECHAT,
            ['account' => $wechatAccount, 'qrcode' => $wechatQrcode],
            ProfileVerifyLog::STATUS_ING
        );
        return [
            'result' => 1,
            'kefu_wechat' => config('busi.kefu_wechat'),
            'kefu_qrcode' => AliyunUtil::IMG_HOST_V2 . 'xinyou_kefu_wechat_04.jpg',
            'rules' => '1、请添加客服微信
2、发送【微信认证 + 帐号ID】
3、客服认证成功则审核通过',
        ];
    }
}
